#include<iostream>

class Base
{
    public:
    virtual void show()
    {
        std::cout << "Base" << std::endl;
    }
    protected:
        int a;
};
class Derived1:public Base
{

    public:
    void show()
    {
        std::cout << "Derived1" << std::endl;
    }
};
class Derived2:public Base
{

    public:
    void show()
    {
        std::cout << "Derived2" << std::endl;
    }
};
int main()
{
    //向上转型
    // Derived *d=new Derived;//基类指针，指向子类对象
    // Base *b = d;
    // b->show();
    // d->show();
    Base *a[2];
    a[0] = new Derived1;
    a[1] = new Derived2;
    //多态
    for (int i = 0; i < 2;i++)
    {
        a[i]->show();

    }
        return 0;
}